package dto

import (
	"time"
	"wxpay/internal/model"
	"wxpay/pkg/util"
)

type ProfitReceiverDTO struct {
	// ID
	ID int64
	// 服务商ID
	MchID string
	// 电商平台的appid(公众号APPID或者小程序APPID)
	AppID string
	// 分账接收方类型
	Type string
	// 分账接收方帐号
	Account string
	// 接收方名称
	Name string
	// .SUPPLIER:供应商;DISTRIBUTOR:分销商;SERVICE_PROVIDER:服务商;PLATFORM:平台;OTHERS:其他
	RelationType string
	// 创建时间
	CreateTime time.Time
	// 修改时间
	UpdateTime time.Time
}

func AdaptProfitReceiver(info *ProfitReceiverDTO) (r model.ProfitReceiver) {
	n := util.GetNow()
	r = model.ProfitReceiver{
		MchID:        info.MchID,
		Appid:        info.AppID,
		Type:         info.Type,
		Account:      info.Account,
		Name:         info.Name,
		RelationType: info.RelationType,
		CreateTime:   n,
		UpdateTime:   n,
	}
	return
}

func ConvertProfitReceiver(info *model.ProfitReceiver) (r *ProfitReceiverDTO) {
	return &ProfitReceiverDTO{
		MchID:        info.MchID,
		AppID:        info.Appid,
		Type:         info.Type,
		Account:      info.Account,
		Name:         info.Name,
		RelationType: info.RelationType,
		CreateTime:   info.CreateTime,
		UpdateTime:   info.UpdateTime,
	}
}
